﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Snowdreamist.Runtime;
using Snowdreamist.Runtime.Services;

namespace Snowdreamist.ComponentModel.MEF
{
    public class MEFModuleDefinition : IModuleDefinition
    {
        public MEFModuleDefinition(Lazy<IModule, IModuleMetadata> lazyObject)
        {
            if (lazyObject == null)
                throw new ArgumentNullException("lazyObject");
            this._lazyObject = lazyObject;
        }

        /// <summary>
        /// Module
        /// </summary>
        internal IModule Value
        {
            get
            {
                return this._lazyObject.Value;
            }
        }

        public string ID
        {
            get
            {
                return this._lazyObject.Metadata.ID;
            }
        }

        public string Name
        {
            get
            {
                return this._lazyObject.Metadata.Name;
            }
        }

        public string Description
        {
            get
            {
                return this._lazyObject.Metadata.Description;
            }
        }

        public string Author
        {
            get
            {
                return this._lazyObject.Metadata.Author;
            }
        }

        public string Version
        {
            get
            {
                return this._lazyObject.Metadata.Version;
            }
        }

        public string Website
        {
            get
            {
                return this._lazyObject.Metadata.Website;
            }
        }

        /// <summary>
        /// Export type
        /// This property is necessary
        /// </summary>
        public Type ExportType
        {
            get
            {
                return this._lazyObject.Metadata.ExportType;
            }
        }

        /// <summary>
        /// Active Type
        /// </summary>
        public ModuleActiveType ActiveType
        {
            get
            {
                return this._lazyObject.Metadata.ActiveType;
            }
        }

        #region private

        private Lazy<IModule, IModuleMetadata> _lazyObject;

        #endregion private
    }
}